/**
 * ===========================================================================
 * 版权所有 湖南免了么网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.mianle.me
 * ===========================================================================
 * 15:27 2018/7/13
 */
package com.mianle.userapi.service.cglib.demo1;

/**
 * @Author: yiyuan
 * @Description:
 * @Date: Created in 15:27 2018/7/13
 */
public class Client {

    public static void main(String[] args) {
        /**************version 1.0**********************/
        //TableDAO tableDao = TableDAOFactory.getInstance();
        //doMethod(tableDao);

        /**************version 2.0**********************/
        //haveNoAuth();

        haveAuthByFilter();


    }

    public static void doMethod(TableDAO dao) {
        dao.create();
        dao.querys();
        dao.update();
        dao.delete();
    }

    public static void haveAuth(){
        TableDAO tDao = TableDAOFactory.getAuthInstance(new AuthProxy("张三"));
        doMethod(tDao);
    }
    public static void haveNoAuth(){
        TableDAO tDao = TableDAOFactory.getAuthInstance(new AuthProxy("李四"));
        doMethod(tDao);
    }

    public static void haveAuthByFilter(){
        System.out.println("---------------------张三调用-------------------");
        TableDAO tDao = TableDAOFactory.getAuthInstanceByFilter(new AuthProxy("张三"));
        doMethod(tDao);

        System.out.println("---------------------李四调用-------------------");
        tDao = TableDAOFactory.getAuthInstanceByFilter(new AuthProxy("李四"));
        doMethod(tDao);
    }
}
